package br.unifor.cct.mia.ga.coevolutionary;

import java.util.HashMap;
import java.util.Map;

import br.unifor.cct.mia.coevolution.CoevolutionaryDomain;
import br.unifor.cct.mia.dataenhancement.Database;
import br.unifor.cct.mia.dataenhancement.Structure;
import br.unifor.cct.mia.evolutionary.SpeciesConstants;
import br.unifor.cct.mia.ga.Ga;

public class RepCoevGaFSHugeScale  extends Ga {
	
	private static String[] configuracoes = {
		"br.unifor.cct.mia.xover.BasicXOver",
		"br.unifor.cct.mia.select.TournamentMaximize",
		"br.unifor.cct.mia.coevolution.evaluate.CoevolutionaryEvaluation",
		"br.unifor.cct.mia.mutation.MutationOriginal",
		"br.unifor.cct.mia.initialize.RepeatableBasicRandomInitialize"
	};
	
	private Structure structure;
	private Database dbOriginal;
	private Map genesAnt;
	
	private CoevolutionaryDomain domain;
	private int speciesCount = 0;
	
	private Integer specieType = new Integer(SpeciesConstants.HUGE_SCALE_FEATURE_SELECTION);
	private int nBits = 0;
	
	public RepCoevGaFSHugeScale(Database dbOriginal, Structure structure, 
			CoevolutionaryDomain domain, int size, int speciesCount, String[] options, int nBits) {
		
		super(size, configuracoes,options);
		System.out.println("Iniciando populacao de FS Huge Scale ("+size+")");
		this.dbOriginal = dbOriginal;
    	this.structure = structure;
    	this.genesAnt = new HashMap();
    	this.domain = domain;
    	this.speciesCount = speciesCount;
    	this.nBits = nBits;
	}
	
	protected void elitist() {		
		super.elitist();
		domain.reloadGraphic(generation,this);
	}
	
	public Object[] getObjectsMutate() {
		Object[] o = new Object[1];
		o[0] = this;
		return o;
	}
	
	public Object[] getObjectsSelect() {
		Object[] o = new Object[1];
		o[0] = this;
		return o;
	}
	
	public Object[] getObjectsEvaluate() {
		Object[] o = new Object[7];
		o[0] = domain;
		o[1] = specieType;
		o[2] = structure;
		o[3] = dbOriginal;
		o[4] = this;
		o[5] = genesAnt;
		o[6] = nBits;
		return o;
	}
	
	public Object[] getObjectsCrossover() {
		Object[] o = new Object[1];
		o[0] = this;
		return o;
	}
	
	public Object[] getObjectsInitialize() {
		Object[] o = new Object[2];	
		o[0] = this;
		o[1] = new Integer(speciesCount);
		return o;
	}        
	
	public Integer getSpecieType() {
		return specieType;
	}

	public void setSpecieType(Integer specieType) {
		this.specieType = specieType;
	}
	
}
